﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

namespace QMSWebService
{
    public class UserManage
    {
        public static string cnstr = ConfigurationManager.ConnectionStrings["HHMSYS"].ConnectionString.ToString();
        /// <summary>
        /// 判断登录是否成功
        /// </summary>
        /// <param name="id"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool Login(string id, string password)
        {
            bool logOrNot = false;

            using (SqlConnection cn = new SqlConnection(cnstr))
            {
                ////获取连接字符串
                //cn.ConnectionString = ConfigurationManager.ConnectionStrings["HHMSYS"].ConnectionString.ToString();

                cn.Open();
                string strSQL = "SELECT FPERSON, FDISPLAYNAME, DEPARTMENT FROM TORGSYSTEM WHERE FPERSON = '"
                    + id + "' and PASSWORD = '" + password + "'";
                SqlCommand cmd = new SqlCommand(strSQL, cn);

                object LogNumber = cmd.ExecuteScalar();
                if (null != LogNumber)
                {
                    logOrNot = true;
                }
                //cn.Close();
            }
            return logOrNot;
        }
    }
}